<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>ES9扩展运算符与rest参数</title>
	</head>
	<body>
		<script>
			// Rest 参数与spread扩展运算符在ES6中已经引入,不过ES6中只针对与数组
			// 在ES9中为对象提供了像数组一样的rest参数和扩展运算符
			function connect({host,port,...user}) {
				console.log(host);
				console.log(port);
				console.log(user);
			}
			connect({
				host:'localhost',
				port:3301,
				username:'admin',
				password:'eeee',
				type:'master'
			})
			const skillOne = {q : 'qqq'};
			const skillTwo = {w : 'www'};
			const skillThree = {a : 'aaa'};
			const mergers = {...skillOne,...skillTwo,...skillThree};
			console.log(mergers);
			// 正则扩展-命名捕获分组
			let str = '<a href="http://www.baidu.com">baidu</a>';
			const reg = /<a href="(?<url>.*)">(?<text>.*)<\/a>/;
			const rs = reg.exec(str);
			console.log(rs.groups);
			// 正则扩展-正向断言
			str = 'ffds32342342fdsfsdf64564645lllll';
			const reg2 = /\d+(?=l)/;
			const rs2 = reg2.exec(str);
			console.log(rs2);
			// 正则扩展-反向断言
			const reg3 = /(?<=f)\d+/;
			const rs3 = reg3.exec(str);
			console.log(rs3);
			// 正则扩展-dotAll
			str = `
			<ul>
				<li>
					<a>AAAA</a>
					<p>1990-09-10</p>
				</li>
				<li>
					<a>BBBB</a>
					<p>1994-07-06</p>
				</li>
			</ul>
			`;
			const reg4 = /<li>.*?<a>(.*?)<\/a>.*?<p>(.*?)<\/p>/gs;
			let rs4;
			let data = [];
			while(rs4 = reg4.exec(str)) {
				//console.log(rs4);
				data.push({title:rs4[1],time:rs4[2]});
			}
			console.log(data);
		</script>
	</body>
</html>